using Light;
using Refresh;
using UnityEngine;
using UnityEngine.UI;


//TODO�������޸Ķ�ӦԤ�Ƽ���text��name���Ų�
/// <summary>
///     ���Item����ʾ��ϸ��Ϣ
/// </summary>
public class ItemDetails : MonoBehaviour, IRefresh
{
    public Text _ID_Name;

    public Text _ID_Damage;

    public Text _ID_Durability;

    public Text _ID_FixNum;

    public Image _ID_Image;

    [SerializeField] private Text textLineOne; //�������˺���������Ҳ���˺�
    [SerializeField] private Text textLineTwo; //������Ӧ�;ã����߶�Ӧ�;á�����������ֵ��̫һ�£����ߵ��;���ʹ�ú�೤ʱ��ʧЧ
    [SerializeField] private Text textLineThree; //������Ӧ�޸����������߶�Ӧ����

    [SerializeField] private GameObject textLineOneGO;
    [SerializeField] private GameObject textLineTwoGO;
    [SerializeField] private GameObject textLineThreeGO;

    public void Refresh<T>(T evt) where T : RefreshData<T>, new()
    {
        var temp = evt as ItemDetailRefreshData;
        var data = temp.data;

        if (data is WeaponItemSO)
        {
            var info = data as WeaponItemSO;
            RefreshWeaponDetails(info);
        }
        else if (data is PropItemSO)
        {
            var info = data as PropItemSO;
            RefreshPropDetails(info);
        }
    }

    private void RefreshWeaponDetails(WeaponItemSO data)
    {
        textLineOne.text = "�˺���";
        textLineTwo.text = "�;ã�";
        textLineThree.text = "���޸�������";

        _ID_Name.text = data.itemName;
        _ID_Durability.text = data.durable.ToString();
        _ID_FixNum.text = data.upCount.ToString();
    }

    private void RefreshPropDetails(PropItemSO data)
    {
        textLineOne.text = "�˺� /s:";
        textLineTwo.text = "����ʱ�䣺";
        textLineThree.text = "������";

        _ID_Name.text = data.itemName;
        _ID_Durability.text = data.durTime.ToString();
        _ID_FixNum.text = 3.ToString(); //��Ҫ����һ�·��͵�ǰ̨�����ݿ��ܻ���ҪЯ���Ŷ���json����
    }
}